#ifndef FUNCTION_H
#define FUNCTION_H

typedef struct {
    COVALUE_HEAD
    CoValue *f_name;  /* CoString: name */
    int f_type;
    int f_num_arg;
    int f_num_local;
    int f_code_size;
    char *f_code;
} CoFunc;

extern CoType CoFunc_Type;

#define COFUNC_CHECK(self)   CO_CHECK_TYPE(self, &CoFunc_Type)

CoValue *CoFunc_New(CoValue *name, int type, int num_arg);
void CoFunc_UpdateDeclaration(CoValue *self, int type, int num_arg);
void CoFunc_UpdateDefination(CoValue *self, int num_local, char *code_start, int code_size);

#define CoFunc_GET_NAME(self)     (((CoFunc *)self)->f_name)
#define CoFunc_GET_TYPE(self)     (((CoFunc *)self)->f_type)
#define CoFunc_GET_NUM_ARG(self)  (((CoFunc *)self)->f_num_arg)
#define CoFunc_GET_NUM_LOCAL(self)  (((CoFunc *)self)->f_num_local)
#define CoFunc_GET_CODE(self)       (((CoFunc *)self)->f_code)

#endif
